package com.lightdz.tshirtdz.general;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

/**
 * Created by Administrator on 2018/12/28.
 * 上传文件的限制
 */

@Configuration
public class UploadFileConfig {
    @Bean
    public MultipartConfigElement getMultipartConfig() {
        MultipartConfigFactory config = new MultipartConfigFactory() ;
        config.setMaxFileSize(DataSize.ofMegabytes(10)); 	// 设置上传文件的单个大小限制
        config.setMaxRequestSize(DataSize.ofMegabytes(100)); 	// 设置总的上传的大小限制
        config.setLocation("/"); // 设置临时保存目录
        return config.createMultipartConfig() ;	// 创建一个上传配置
    }
}
